package com.example.zydraw.draw;

import android.graphics.Color;
import android.graphics.Paint;


public class PaintRecord {

    public PaintRecord() {
    }

    private float textSize = 18f;

    private int color = Color.BLACK;
    private float strokeWidth = 1f;

    private Paint.Style style = Paint.Style.FILL;

    private int alpha = 255;


    private Paint.Align textAlign = Paint.Align.CENTER;

    private boolean isAntiAlias = false;

    public Paint toPaint() {
        Paint paint = new Paint();
        paint.setTextSize(textSize);
        paint.setColor(color);
        paint.setStrokeWidth(strokeWidth);
        paint.setStyle(style);
        paint.setAlpha(alpha);
        paint.setTextAlign(textAlign);
        paint.setAntiAlias(isAntiAlias);
        return paint;
    }


    public void setTextSize(float textSize) {
        this.textSize = textSize;
    }

    public void setColor(int color) {
        this.color = color;
    }

    public void setStrokeWidth(float strokeWidth) {
        this.strokeWidth = strokeWidth;
    }

    public void setStyle(Paint.Style style) {
        this.style = style;
    }

    public void setAlpha(int alpha) {
        this.alpha = alpha;
    }

    public void setTextAlign(Paint.Align textAlign) {
        this.textAlign = textAlign;
    }

    public void setAntiAlias(boolean antiAlias) {
        isAntiAlias = antiAlias;
    }

    @Override
    public String toString() {
        return "PaintRecord{" +
                "textSize=" + textSize +
                ", color=" + color +
                ", strokeWidth=" + strokeWidth +
                ", style=" + style +
                ", alpha=" + alpha +
                ", textAlign=" + textAlign +
                ", isAntiAlias=" + isAntiAlias +
                '}';
    }

    public void update(Paint paint) {
        if (paint.getTextSize() != textSize){
            paint.setTextSize(textSize);
        }
        paint.setColor(color);
        paint.setStrokeWidth(strokeWidth);
        paint.setStyle(style);
        paint.setAlpha(alpha);
        paint.setTextAlign(textAlign);
        paint.setAntiAlias(isAntiAlias);
    }
}
